package com.security.brows.base

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.livedata.observeAsState
import com.hub.videobrowsdownload.BrowsApplication
import com.security.brows.values.DarkColorScheme
import com.security.brows.values.DarkDrawableScheme
import com.security.brows.values.LightColorScheme
import com.security.brows.values.LightDrawableScheme
import com.security.brows.values.SecurityBrowsColorsScheme
import com.security.brows.values.SecurityBrowsDrawable

abstract class SecurityBaseActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        preContent()
        setContent {
            val isSystemInDarkTheme = BrowsApplication.browsMyViewModel.isDarkTheme.observeAsState()
            ComposeContent(isSystemInDarkTheme.value?:false, getColorScheme(), getDrawableScheme())
        }
    }

    open fun preContent(){

    }
    @Composable
    abstract fun ComposeContent(isDarkTheme: Boolean, colorsScheme: SecurityBrowsColorsScheme, drawableScheme: SecurityBrowsDrawable)


    @Composable
    fun getColorScheme():SecurityBrowsColorsScheme {
        val isSystemInDarkTheme = BrowsApplication.browsMyViewModel.isDarkTheme.observeAsState()
        return if (isSystemInDarkTheme.value == true) {
            DarkColorScheme
        }else{
            LightColorScheme
        }
    }

    @Composable
    fun getDrawableScheme(): SecurityBrowsDrawable {
        val isSystemInDarkTheme = BrowsApplication.browsMyViewModel.isDarkTheme.observeAsState()
        return if (isSystemInDarkTheme.value == true) {
            DarkDrawableScheme
        }else{
            LightDrawableScheme
        }
    }

}